<template>
<view v-if="showuid" :style="theme" class="page">
	
	<!--设置-->
	<view class="d-kuan">
		<view class="d-neikuang-10">
			<view class="d-kuan d-yuanjiao-10 d-beijing-bai">
				<view class=" d-neikuang-10">
					<u-cell
						icon="order"
						size="large"
						title="昵称设置"
						value=""
						:titleStyle="{'color': fenggeyanse =='light'? '#0d0d0d':'#f5f9ff'}"
						isLink
						@click="ziliao()"
					></u-cell>
					<u-cell
						icon="account"
						size="large"
						:titleStyle="{'color': fenggeyanse =='light'? '#0d0d0d':'#f5f9ff'}"
						title="用户认证"
						value=""
						isLink
						@click="renzheng()"
					></u-cell>
					<view class="d-clear"></view>
				</view>
			</view>
		</view>
	</view>
	
	
	<!-- 版权信息template模板 -->
	<view class="copyright" >
		<block data-type="template" data-is="tempCopyright" data-attr="webSiteName:webSiteName,domain:domain">
			<view> {{webSiteName}} </view>
			<view> {{banbenhao}} </view>
		</block>
	</view>
	
</view>
<view v-else>
	<view class="d-kuan d-neikuang-10">
		
		<view class="u-content">
			<view class="u-content__circle">
				<u-icon
					name="checkbox-mark"
					color="#fff"
					size="30"
				></u-icon>
			</view>
			<text class="u-content__normal">跳转登录</text>
		</view>
	</view>
</view>
</template>

<script>

var Api = require("../../utils/api.js");
var util = require("../../utils/util.js");

var wxApi = require("../../utils/wxApi.js");
var wxRequest = require("../../utils/wxRequest.js");
import config from "../../utils/config";
var pageCount = config.getPageCount;
var webSiteName = config.getWebsiteName;
var domain = config.getDomain;
var banbenhao = config.getDuixinbanbenhao;
const app = getApp();
/*#ifdef APP-PLUS || H5*/
	var code = uni.getStorageSync('userInfo');
/*#endif*/
/*#ifdef MP-WEIXIN*/
    var code = uni.getStorageSync('userInfo');
/*#endif*/

export default {
  data() {
    return {
      isArticlesList: true,
      listStyle: config.getListStyle,
      shareTitle: config.getWebsiteName,
      pageTitle: '我的',
      articlesList: [],
	  yonghuXinxi: [],
      postype: "post",
      webSiteName: webSiteName,
	  banbenhao: banbenhao,
      domain: domain,
	  member: [],
	  code:code,
	  show: false,
	  showuid: false,
	  fenggeyanse:'',
    };
  },

  components: {},
  props: {},
  onShow: function () {
	  var duixin = this;

	// 暗黑模式
	var initialThemes = uni.getStorageSync('theme');
	duixin.fenggeyanse = initialThemes;
	uni.setNavigationBarColor({
		backgroundColor: this.fenggeyanse =='light'? '#ffffff':'#151515',
		frontColor: this.fenggeyanse =='light'? '#000000':'#ffffff',
	})
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
	  var self = this; 

	uni.reLaunch();
	  
	  
	    
	//判断用户是否登录
	var userInfo = uni.getStorageSync('userInfo');
	
	if (userInfo) {
		this.showuid = true;
		var member = uni.getStorageSync('member');
		var memberuid = uni.getStorageSync('memberuid');
		//console.log("member1",member);
		//console.log("userInfo1",userInfo);
		// 保留二次开发
		self.getYonghuXinxi(memberuid);
	} else {
		//否则跳转到登录页面
		uni.reLaunch({ url: '/pages/login/login'}) // 跳转到首页
	}
	
    var postype = 'post';

    if (options.postype) {
      postype = options.postype;
    }
	
    this.setData({
      postype: postype
    });
  },
  onReady: function () {
    uni.setNavigationBarTitle({
      title: this.pageTitle
    });
  },
  methods: {
	bangdingYicun(){
		uni.navigateTo({
		  url: '/pages/wo/xiaochengxuguanli',
		  
		});
		console.log('open');
	},
	open() {
	// console.log('open');
	},
	close() {
	this.show = false
	// console.log('close');
	},
	//会员信息
	getYonghuXinxi(uid) {
		var self = this; 
		self.setData({
		  yonghuXinxi: []
		});
		
		var getYonghuXinxiRequest = wxRequest.getRequest(Api.getYonghuXinxi(uid));
		getYonghuXinxiRequest.then(response => {
			if (response.data.code == 1) {
			  
			  self.yonghuXinxi = response.data.data
			} else {
			  self.setData({
				displaySwiper: "none"
			  });
			}
		});
	},

    formSubmit: function (e) {
      var url = '../list/list';
      var key = '';

      if (e.currentTarget.id == "search-input") {
        key = e.detail.value;
      } else {
        key = e.detail.value.input;
      }

      if (key != '') {
        url = url + '?search=' + key;
        uni.navigateTo({
          url: url
        });
      } else {
        uni.showModal({
          title: '提示',
          content: '请输入内容',
          showCancel: false
        });
      }
    },
    // 跳转至查看文章详情
    redictDetail: function (e) {
      Adapter.redictDetail(e, "post");
    },
	exitlogin() {
		uni.removeStorageSync('userInfo');
		uni.removeStorageSync('memberuid');
		uni.reLaunch({ url: '/pages/login/login'})
	},
	xcxWxBangding() { 
		let data = {
		        oid: member.openids.id,
				//data: this.yonghuming
				
		        data:JSON.stringify({
					username: 'admin',
					password: '520520sjgx',
				})
		    };
		uni.request({
	    url: Api.getWeixinBangding(), // 替换为您要提交POST请求的URL
		method: 'POST',
		header: {
		    'Content-Type': 'application/x-www-form-urlencoded',
		},
		data: data,
			success: function (res) {
			console.log("oid",member.openids.id) // 打印服务器返回的数据
				uni.showModal({
					showCancel: false,
					content: res.data.msg
				})
			},
			fail: function (err) {
			console.error(err) // 打印错误信息
				uni.showModal({
					showCancel: false,
					content: res.data.msg
				})
			}
		})
	},
	//
	renzheng(){
		uni.navigateTo({
		  url: '/pages/shezhi/renzheng',
		});
	},
	// 资料
	ziliao() {
		uni.navigateTo({
		  url: '/pages/shezhi/ziliao',
		});
	}
	
  }
};
</script>
<style lang="scss">
@import "./shezhi.css";
page {
	background-color: var(--nav-color-bg);
}
</style>